package com.xxk.rocket.star.core.builder;

import com.xxk.rocket.star.core.annotation.IProcessAnnotationConsume;
import com.xxk.rocket.star.core.annotation.IProcessAnnotationProducer;
import com.xxk.rocket.star.core.annotation.impl.*;
import com.xxk.rocket.star.core.client.IProcessClientConsume;
import com.xxk.rocket.star.core.client.IProcessClientProducer;
import com.xxk.rocket.star.core.client.impl.ConsumeBaseProcessClientConsume;
import com.xxk.rocket.star.core.client.impl.MapperProcessClientConsume;
import com.xxk.rocket.star.core.message.IProcessMessageConsume;
import com.xxk.rocket.star.core.message.IProcessMessageProducer;
import com.xxk.rocket.star.core.message.impl.CoreProcessMessageConsume;
import com.xxk.rocket.star.core.message.impl.CoreProcessMessageProducer;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ProcessCenter {

  private static final ProcessCenter processCenter = new ProcessCenter();

  private List<IProcessAnnotationConsume> processAnnotationConsumes = Collections
          .synchronizedList(new ArrayList<>());
  private List<IProcessAnnotationProducer> processAnnotationProducers = Collections
          .synchronizedList(new ArrayList<>());

  private List<IProcessClientConsume> processClientConsumes = Collections
          .synchronizedList(new ArrayList<>());
  private List<IProcessClientProducer> processClientProducers = Collections
          .synchronizedList(new ArrayList<>());

  private List<IProcessMessageConsume> processMessageConsumes = Collections
          .synchronizedList(new ArrayList<>());
  private List<IProcessMessageProducer> processMessageProducers = Collections
          .synchronizedList(new ArrayList<>());

  private ProcessCenter() {
    processAnnotationConsumes.add(new MethodsProcessConsumeAnnotation());
    processAnnotationConsumes.add(new StargateMapperProcessAnnotation());
    processAnnotationConsumes.add(new StargateFromWhereProcessAnnotation());
    processAnnotationConsumes.add(new StargateBodyProcessAnnotation());
    processAnnotationConsumes.add(new StargateDecodeProcessAnnotation());
    processAnnotationConsumes.add(new StargateThreadSizeProcessAnnotation());
    processAnnotationConsumes.add(new StargateNameServerProcessAnnotation());
    processAnnotationConsumes.add(new StargateBroadcastingProcessAnnotation());
    processAnnotationConsumes.add(new StargatePullBatchSizeProcessAnnotation());

    processAnnotationProducers.add(new MethodsProcessProducerAnnotation());
    processAnnotationProducers.add(new StargateMapperProcessAnnotation());
    processAnnotationProducers.add(new StargateBodyProcessAnnotation());
    processAnnotationProducers.add(new StargateEncodeProcessAnnotation());
    processAnnotationProducers.add(new StargateOneWayProcessAnnotation());
    processAnnotationProducers.add(new StargateDelayMsecProcessAnnotation());
    processAnnotationProducers.add(new StargateDelayLevelProcessAnnotation());
    processAnnotationProducers.add(new StargateNameServerProcessAnnotation());
    processAnnotationProducers.add(new StargateDelayParamProcessAnnotation());

    processClientConsumes.add(new ConsumeBaseProcessClientConsume());
    processClientConsumes.add(new MapperProcessClientConsume());

    processMessageProducers.add(new CoreProcessMessageProducer());

    processMessageConsumes.add(new CoreProcessMessageConsume());
  }

  public static ProcessCenter getInstance() {
    return processCenter;
  }

  public static List<IProcessAnnotationConsume> getConsumeAnnotationProcess() {
    return getInstance().processAnnotationConsumes;
  }

  public static List<IProcessAnnotationProducer> getProducersAnnotationProcess() {
    return getInstance().processAnnotationProducers;
  }

  public static List<IProcessClientConsume> getConsumeClientProcess() {
    return getInstance().processClientConsumes;
  }

  public static List<IProcessClientProducer> getProducersClientProcess() {
    return getInstance().processClientProducers;
  }

  public static List<IProcessMessageConsume> getConsumeMessageProcess() {
    return getInstance().processMessageConsumes;
  }

  public static List<IProcessMessageProducer> getProducersMessageProcess() {
    return getInstance().processMessageProducers;
  }

}
